<% @page_title = "Procura de Livros" %>

<h1>Resultados da procura</h1>

<table cellpadding="7" cellspacing="0">
  <tr>
    <th>Título</th>
    <th>Autor</th>
    <th>Editora</th>
    <th>Categoria</th>
  </tr>

  <% for book in session[:books] -%>
    <tr class="entry">
      <!-- <td><%= link_to "#{book.title}", :action => :show, :id => book.id %></td> -->
      <td><%= link_to "#{book.title}", book_path(book) %></td>
      <td><%= book.author %></td>
      <td><%= book.publisher %></td>
      <td><%= book.category %></td>
      <% if book.quantity == 0 %>
        <td>Indisponível</td>
      <% end %>
      <% if book.quantity > 0 %>
        <td><%= link_to "Emprestar", :action => :select_user, :id => book %></td>
      <% end %>
      <td><%= link_to 'Editar', edit_book_path(book) %></td>
      <td><%= link_to 'Excluir', book, :confirm => "Deseja realmente excluir o livro #{book.title}?", :method => :delete %></td>
    </tr>
  <% end %>

</table>

<br /> <%= link_to "Nova Busca", :controller => 'books', :action => 'index' %>
